from pyspark import SparkConf, SparkContext
import os
os.environ['PYSPARK_PYTHON'] = r"C:\Users\admin\AppData\Local\Programs\Python\Python38\python.exe"
conf = SparkConf().setMaster("local[*]").setAppName("test_spark")
sc = SparkContext(conf=conf)
# 准备一个RDD
rdd = sc.parallelize(["itheima itcast 666", "itheima itheima itcast", "python itheima"])
# 需求，将RDD数据里面的一个个单词提取出来
# flatMap比map多出解除一层嵌套的功能
rdd2 = rdd.flatMap(lambda x: x.split(" "))
print(rdd2.collect())
